<?php require 'backuptweets.php'; ?>
<!doctype html>
<html>
<head>
    <meta charset="utf-8" />
    <title>BackupTweets</title>
    <link rel="stylesheet" type="text/css" href="http://static.haykranen.nl/common/style.css" />
    
    <?php echo file_get_contents('http://static.haykranen.nl/common/nav/html/head.php'); ?>
</head>
<body>

<?php echo file_get_contents('http://static.haykranen.nl/common/nav/html/nav.php'); ?>

<div id="wrapper">
    <h1>
        <a href="index.php">BackupTweets</a>
    </h1>

<?php if (empty($_POST)) : ?>
    <div style="float:left;">
        <img src="logo.png" alt="" style="float:right;"/>
        <p>This is a simple application that allows you to backup your
        <a href="http://www.twitter.com">Twitter</a> tweets.</p>

        <p>Your tweets will be saved in the <a href="http://en.wikipedia.org/wiki/JSON">JSON</a>
        format for good archiving, but also in a single HTML file for easy
        viewing.</p>

        <p>Read more about this app
        <a href="http://www.haykranen.nl/projects/backuptweets">on the BackupTweets website</a>.</p>
        <p>This is an open source application, released
        under the <a href="http://www.gnu.org/copyleft/gpl.html">GNU General Public License</a>
        version 3, or (at your option) any later version. You can download the source
        from the <a href="http://www.haykranen.nl/projects/backuptweets">website</a>
        as well.</p>
        <p>This application is written by <a href="http://www.haykranen.nl/en">Hay Kranen</a>.
        If you like this app <a href="http://www.twitter.com/huskyr">follow me</a>
        on Twitter or send me a nice <a href="mailto:hay@bykr.org">email</a>.</p>

        <hr />

        <p><em>Enter your Twitter username and password below</em></p>
        <form method="post" action="index.php">
            <input type="text" maxlength="15" id="user" name="user" />
            <label for="user">Username</label>
            <br />

            <input type="password" id="pass" name="pass" />
            <label for="password">Password</label>
            <br />

            <button type="submit">GO</button>
        </form>

        <p><em>Your username and password won't be saved, but if you're scared anyway
        remember you can run this application on your local machine as well.</em></p>
    </div>
<?php else : ?>
    <h3>Your backup has been started. Don't close this window or press the 'stop' button!</h3>
    
    <pre class="code">
        <?php backuptweets(); ?>
    </pre>

    <h2>Your backup is ready!</h2>
    <ul>
        <li>
            <a href="tweets/<?php echo $user; ?>.json">Download the complete backup here</a>
            (Right-click and select 'Save link as')
        </li>
        <li>
            <a href="tweets.php?user=<?php echo $user; ?>">View all your tweets 
            here in a nicely layouted HTML file</a>
        </li>
    </ul>
<?php endif; ?>
</div> <!-- /wrapper -->
</body>
</html>